package com.fms.player.mvc
{
	import com.fms.player.mvc.command.StudentLiveCmd;
	import com.fms.player.mvc.command.TeacherLiveCmd;
	import com.fms.player.mvc.command.VodCmd;
	import com.fms.player.mvc.proxy.FMSPlayerProxy;
	
	import mx.controls.Alert;
	
	import org.puremvc.as3.patterns.facade.Facade;
	
	public class FMSFacade extends Facade
	{
		public function FMSFacade()
		{
			super();
		}
		
		public static function getInstance():FMSFacade
		{
			if (!instance)
				instance = new FMSFacade();
			return instance as FMSFacade;
		}
		
		/**
		 * 程序的启动方法，发startup消息，由StartupCommand执行
		 * */
		public function startUp(app:FMSPlayer, type:String, role:String):void
		{
			_mainUI = app;
			
			switch(type){
				case "live":
					if(role == "teacher"){
						sendNotification(PublicNotify.CREATE_LIVE_TEACHER_APP, app);
					}else if(role == "student"){
						sendNotification(PublicNotify.CREATE_LIVE_STUDENT_APP, app);
					}else{
					}
					break;
				case "vod":
					sendNotification(PublicNotify.CREATE_VOD_APP, app);
					break;
			}
		}
		
		override protected function initializeController():void
		{
			super.initializeController();
			registerCommand(PublicNotify.CREATE_LIVE_TEACHER_APP, TeacherLiveCmd);
			registerCommand(PublicNotify.CREATE_LIVE_STUDENT_APP, StudentLiveCmd);
			registerCommand(PublicNotify.CREATE_VOD_APP, VodCmd);
		}
		
		/**
		 * 初始数据代理层
		 */
		override protected function initializeModel():void
		{
			super.initializeModel();
			//registerProxy(new FMSPlayerProxy());
		}
		
		//父窗体		
		private var _mainUI:FMSPlayer;
		public function get mainUI():FMSPlayer
		{
			return _mainUI;
		}
	}
}